package com.reggie.dish.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.reggie.dish.entity.Dish;
import com.reggie.dish.entity.DishFlavor;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DishDao extends BaseMapper<Dish> {

    @Select("select * from dish where category_id = #{categoryId}")
    List<Dish> selectByCategoryID(Long categoryId);

    @Select("select * from dish_flavor where dish_id = #{id}")
    List<DishFlavor> selectFlavorById(Long id);

    @Update("UPDATE dish SET status = #{status} WHERE `id` = #{id}; ")
    void updateStatus(@Param("id") Long id, @Param("status") int status);
}
